<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8"/>
        <title>过滤敏感词</title>
        <script>
            window.onload = function () {
                var aTextarea = document.getElementsByTagName("textarea");
                var oBtn = document.getElementById("btn");
                
                oBtn.onclick = function () {
                    var re = /军|核弹|攻击|侵略活动/g;
                    
                    aTextarea[1].value = aTextarea[0].value.replace( re, function (str) {
                        var result = "";
                        for(var i=0; i<str.length; i++) {
                            result += "*";
                        };
                        return result;
                    } );
                }
            }
        </script>
    </head>
    <body>
        <p>原内容</p>
        <textarea></textarea>
        <p>显示内容</p>
        <textarea></textarea>
        <input type="button" value="过滤敏感词" id="btn"/>
    </body>
</html>